/*************************************************
Author: byron
Date: 10/16/2012
Description:
Notes:
*************************************************/

#ifndef __CRoleMgr_h__
#define __CRoleMgr_h__

#include "commclass.h"

class CPlayerAttr;
class CPlayerOnlineData;
class MsgRoleInfo;
class MsgReqGMPlayer;
class MsgAnsGMPlayer;
class MsgRoleBaseAttrs;
class MsgRoleFightAttrs;
class CPlayerSnsCommInfo;

class CRoleMgr
{
public:
    CRoleMgr()
    {
    }

    virtual ~CRoleMgr()
    {
    }

    unsigned int GetNewGID();

    int GetRoleFighting(CPlayerOnlineData& stPlayerOnline);
    int GetTeamFighting(CPlayerOnlineData& stPlayerOnline);
    int GetMountFighting(unsigned int uiMountID, int iSkillLevel);

    int RoleChkEquipStat(CPlayerDetailInfo& stPlayerDetail, unsigned int uiEquipID, int iPos);

    int ReCalcRoleExtAttr(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfo& stPlayerDetail,
            CPlayerOnlineData& stPlayerOnline,
            CPlayerDetailInfoEx1& stPlayerDetailEx1, bool bSendTeamFighting);

    int RoleWearEquip(CPlayerBaseInfo& stPlayerBase, CPlayerDetailInfo& stPlayerDetail, CPlayerOnlineData& stPlayerOnline, unsigned int uiEquipID, int iPos);

    int RoleTakeOffEquip(CPlayerBaseInfo& stPlayerBase, CPlayerDetailInfo& stPlayerDetail, CPlayerOnlineData& stPlayerOnline, unsigned int uiEquipID, int iPos);

    int RoleAddExp(CPlayerBaseInfo& stPlayerBase,
            CPlayerDetailInfo& stPlayerDetail,
            CPlayerOnlineData& stPlayerOnline,
            CPlayerDetailInfoEx1& stPlayerDetailEx1, int64 i64AddExp);

    int GMDealRole(CPlayerBaseInfo& stPlayerBase, CPlayerDetailInfo& stPlayerDetail, CPlayerOnlineData& stPlayerOnline, MsgReqGMPlayer& stReq, MsgAnsGMPlayer& stAns);

    int GMCopyRoleAttr(CPlayerAttr& stPlayerAttr, MsgAnsGMPlayer& stAns);

    int CopyRoleInfo(CPlayerBaseInfo& stPlayerBase, CPlayerDetailInfo& stPlayerDetail, CPlayerOnlineData& stPlayerOnline, CPlayerSnsCommInfo& stPlayerSnsComm, MsgRoleInfo& stMsgRoleInfo);

    int CopyBaseAttr(CPlayerAttr& stPlayerAttr, MsgRoleBaseAttrs& stMsgBaseAttr);

    int CopyExtAttr(CPlayerAttr& stPlayerAttr, MsgRoleFightAttrs& stMsgExtAttr);

    int CalcFighting(CPlayerAttr& stPlayerAttr, int& iFighting);

    int CalcObjFighting(unsigned int uiGID, int iObjType, int iAuxData);

    int GetRoleLevel(unsigned int uiGid, short & shRoleLevel);

    const char * GetRoleName (unsigned int uiGid);

    int SubGold(unsigned int uiGid, short & shRoleLevel);

    void DumpOnlineRoleInfo(CPlayerAttr& stPlayerAttr);

    int CheckValidCareer(int iCareer);

    int CheckValidBaseAttr(int iBaseType);

    int CheckValidCareerAttr(int iID);

    int GetCareerAttrID(int iCareer, int iBaseType, int& iID);

    int GetCareerBaseTypeByID(int& iCareer, int& iBaseType, int iID);

    int GetRoleInitBaseAttr(CPlayerAttr& stPlayerAttr, int iCareer);

    int CalcCareerLevelAttr(CPlayerAttr& stPlayerAttr, int iCareer, int iLevel,
        bool bCalcExtAttr);

    int CalcCareerBaseToExtAttr(CPlayerAttr& stAttr, int iCareer);

    int AddObjTurnOrder(CPlayerAttr& stAttr, int iObjType,
        unsigned int uiObjID, CPlayerDetailInfo& stPlayerDetail,
        CPlayerOnlineData& stPlayerOnline);

    void UpdateFightingInSns (CPlayerOnlineData& stPlayerOnline);

    void DropTitle (unsigned int uiGID, EN_ROLE_TITLE_TYPE enTitle, int iExpiredTime);

    int CheckRoleFreeze(CPlayerBaseInfo& stPlayerBase, int iFreezeType);

    //按自然日计算这是用户第几天登陆游戏
    void UpdateLoginDays (CPlayerDetailInfoEx1 & stDetail, int iNowTime);

    //按自然日计算用户的当日在线时间
    int GetTodayOnlineSeconds (CPlayerSnsDetailInfo& stSnsDetail, int iNowTime);

    //检查用户是否存在. (存在为真,否则为假)
    bool CheckRoleExist (unsigned int uiGID);
};

#endif // __CRoleMgr_h__
